import React from "react";
import { NavLink, Routes, Route } from "react-router-dom";

// import "./06-style.css";

const Home = () => {
  return <div>这是首页</div>;
};
const About = () => {
  return <div>这是关于页</div>;
};

const App = () => {
  return (
    <>
      <h2>路由高亮-v6</h2>
      <ul>
        <li>
          {/* NavLink没有activeClassName了 */}
          {/* NavLink的className和style允许写函数，函数可以接受一个对象，对象里面有isActive表示当前的这个NavLink是否被选中 */}
          <NavLink
            to="/home"
            className={({ isActive }) => {
              return isActive ? "abc" : "";
            }}
          >
            首页
          </NavLink>
        </li>
        <li>
          <NavLink
            to="/about"
            style={({ isActive }) => {
              return isActive ? { color: "green" } : {};
            }}
          >
            关于页
          </NavLink>
        </li>
      </ul>

      <hr />

      <Routes>
        <Route path="*" element={<div>404 not found...</div>}></Route>
        <Route path="/home" element={<Home />}></Route>
        <Route path="/about" element={<About />}></Route>
      </Routes>
    </>
  );
};

export default App;
